package org.openkoala.demo.core.domain;


import java.util.List;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.dayatang.domain.AbstractEntity;

/**参与者*/
@Entity
@Table(name = "PARTY")
@DiscriminatorValue("PARTY")
public class Party extends AbstractEntity {

    /**null*/
    @Column(name = "NAME")
    private String name;

    /**null*/
    @Column(name = "SN")
    private String sn;

    Party() {
    }

    /**
     * 取得null
     * @return name null
     */
    public String getName() {
        return name;
    }

    /**
     * 设置null
     * @param name null
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 取得null
     * @return sn null
     */
    public String getSn() {
        return sn;
    }

    /**
     * 设置null
     * @param sn null
     */
    public void setSn(String sn) {
        this.sn = sn;
    }

    /**
     * null
     * @return void
     */
    public void remove() {
    }

    /**
     * null
     * @return void
     */
    public void save() {
    }


    public static List<Party> findAll() {
        return getRepository().findAll(Party.class);
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37).append(this.getName()).append(this.getSn()).toHashCode();
    }

    @Override
    public boolean equals(Object other) {
        if (!(other instanceof Party)) {
            return false;
        }
        Party that = (Party) other;
        return new EqualsBuilder().append(this.getName(), that.getName()).append(this.getSn(), that.getSn()).isEquals();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).append(this.getName()).append(this.getSn()).build();
    }
}
